<!DOCTYPE html>
<html>
<head>
    {include file="public/header" /}
    <style>
        .zhuce{
            margin-left: -20px
        }
        .rq{
            width: 150px;
        }
        .sousuo{
            margin-left: 55px;width:126%;
        }
        .sbtn{
            margin-left: 140px
        }
    </style>
</head>
<body>
<div class="layui-form layuimini-form">
    <span class="layui-badge ">领导人信息</span>
    <table class="layui-table layui-form">
        <thead>
        <tr>
            <th>领导人名称</th>
            <th>领导人ID</th>
            <th>手机号</th>
            <th>注册日期</th>
            <th>玩家等级</th>
            <th>所属团队</th>
            <th>性别</th>
            <th>年龄</th>
            <th>地区</th>
            <th>玩家类型</th>
            <th>状态</th>
        </tr>
        </thead>
        <tbody>
        <tr onclick='memberDetail("{$code}")'>
            <td>{$info.name}</td>
            <td>{$info.code}</td>
            <td>{$info.phone}</td>
            <td>{$info.register_time}</td>
            <td>{$info.levelTitle}</td>
            <td>{$info.teamTitle}</td>
            <td>
                {if condition="$info.sex == 1"}男{/if}
                {if condition="$info.sex == 2"}<span style="color: #F581B1;"> 女</span>{/if}
            </td>
            <td>{$info.age}</td>
            <td>{$info.address}</td>
            <td>
                {if condition="$info.type == 1"}<span style="color: #28f51d;">账号正常</span>{/if}
                {if condition="$info.type == 2"}<span style="color: #f59b28;">合伙人</span>{/if}
                {if condition="$info.type == 3"}<span style="color: #f42540;">账号封停</span>{/if}
                {if condition="$info.type == 4"}<span style="color: rgba(0,0,0,0.11);">玩家退出</span>{/if}
            </td>
            <td>
                {if condition="$info.status == 1"}未注册{/if}
                {if condition="$info.status == 2"}已注册{/if}
                {if condition="$info.status == 3"}未激活{/if}
                {if condition="$info.status == 4"}等待审核{/if}
                {if condition="$info.status == 5"}已激活{/if}
            </td>

        </tr>
        </tbody>
    </table>
    <span class="layui-badge  layui-bg-green" >我的团队信息</span>

    <div class="layuimini-main">
        <form class="layui-form layui-form-pane" action="">
                <!--<legend>搜索信息</legend>-->
                <div style="margin: 10px 10px 10px 10px">

                 <!--   <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">玩家名称</label>
                            <div class="layui-input-inline">
                                <input type="text" name="search" autocomplete="off" placeholder="【名称】【手机号】【玩家ID】" class="layui-input">
                            </div>
                        </div>-->
                       <!-- <div class="layui-inline">
                            <label class="layui-form-label">玩家手机号</label>
                            <div class="layui-input-inline">
                                <input type="text" onkeyup="this.value=this.value.replace(/[^0-9-]+/,'');" maxlength="11" name="phone" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">玩家ID</label>
                            <div class="layui-input-inline">
                                <input type="text" name="code" autocomplete="off" class="layui-input">
                            </div>
                        </div>-->
                        <div class="layui-inline">
                            <label class="layui-form-label zhuce" >注册时间</label>
                            <div class="layui-input-inline rq" >
                                <input type="text" name="register_min" id="register_min" placeholder="起始日期" autocomplete="off" class="layui-input">
                            </div>
                            <div class="layui-form-mid"></div>-
                            <div class="layui-input-inline rq" >
                                <input type="text" name="register_max" id="register_max" placeholder="结束日期" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <!--<label class="layui-form-label">玩家名称</label>-->
                            <div class="layui-input-inline">
                                <input type="text" name="search" autocomplete="off" placeholder="可按【名称】【手机号】【玩家ID】搜索" class="layui-input sousuo" >
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button type="submit" class="layui-btn layui-btn-primary sbtn" lay-submit lay-filter="data-search-btn" ><i class="layui-icon"></i> 搜 索</button>
                        </div>
                    </div>

                </div>
        </form>
        <table class="layui-hide" id="currentTableId" lay-filter="currentTableFilter">
        </table>
        <script type="text/html" id="currentTableBar">
            <a class="layui-btn layui-btn-normal layui-btn-xs data-count-edit" lay-event="detail">查看详情</a>
        </script>
    </div>

</div>
{include file="public/footer" /}

<!--性别-->
<script type="text/html" id="sexTpl">
    {{#  if(d.sex === 2){ }}
    <span style="color: #F581B1;"> 女</span>
    {{#  } else { }}
    <span>男</span>
    {{#  } }}
</script>
<script type="text/html" id="typeTpl">
    {{#  if(d.type === 1){ }}
    <span style="color: #28f51d;">账号正常</span>
    {{# }else if(d.type === 2){ }}
    <span style="color: #f59b28;">合伙人</span>
    {{# }else if(d.type === 3){ }}
    <span style="color: #f42540;">账号封停</span>
    {{#  } else { }}
    <span style="color: rgba(0,0,0,0.11);">玩家退出</span>
    {{#  } }}
</script>
<script type="text/html" id="statusTpl">
    {{#  if(d.status === 1){ }}
    <span>未注册</span>
    {{# }else if(d.status === 2){ }}
    <span>已注册</span>
    {{# }else if(d.status === 3){ }}
    <span>未激活</span>
    {{# }else if(d.status === 4){ }}
    <span>等待审核</span>
    {{#  } else { }}
    <span>已激活</span>
    {{#  } }}
</script>
<script>
    layui.use(['form', 'table','laydate','layarea'], function () {
        var $ = layui.jquery,
            form = layui.form,
            laydate = layui.laydate,
            layarea = layui.layarea,
            table = layui.table;
        /*城市级联*/
        layarea.render({
            elem: '#area-picker',
            data: {
                province: "{$info.province}",
                city: "{$info.city}",
                county: "{$info.area}"
            },
            change: function (res) {
            }
        });
        /*注册时间-最小*/
        $(this).removeAttr("lay-key");//时间框一点就消失处理
        laydate.render({
            elem: '#register_min'
            , trigger : 'click'//时间框一点就消失处理
        });
        /*注册时间-最大*/
        laydate.render({
            elem: '#register_max'
            , trigger : 'click'//时间框一点就消失处理


        });
        table.render({
            elem: '#currentTableId',
            url: '/admin/team/getTeamMember?teamId={$teamId}&active=ajax',
            method: 'post',
            parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.data.total, //解析数据长度
                    "data": res.data.data, //解析数据列表
                };
            },
            defaultToolbar:'',
            cols: [[
                {field: 'name', title: '玩家名称', sort: false,},
                {field: 'code', title: '玩家ID', sort: false,minWidth:100},
                {field: 'phone', title: '手机号', sort: false,minWidth:120},
                {field: 'register_time', title: '注册日期', sort: false,minWidth:160},
                {field: 'levelTitle', title: '玩家等级', sort: false,},
                {field: 'teamTitle', title: '所属团队', sort: false},
                {field: 'sex', title: '性别', sort: false, templet: '#sexTpl'},
                {field: 'age', title: '年龄', sort: false,},
                {field: 'address', title: '地区', sort: false,},
                {field: 'type', title: '玩家类型', sort: false, templet: '#typeTpl',},
                {field: 'status', title: '状态', sort: false, templet: '#statusTpl'},
                {title: '操作', toolbar: '#currentTableBar', align: "center"}

            ]],
            limits: [10, 15, 20, 25, 50, 100],
            limit: 10,
            page: true,
            skin: 'line'
        });

        // 监听搜索操作
        form.on('submit(data-search-btn)', function (data) {
            var result = JSON.stringify(data.field);
            //执行搜索重载
            table.reload('currentTableId', {
                page: {
                    curr: 1
                }
                , where: {
                    searchParams: result
                }
            }, 'data');

            return false;
        });


        /**
         * toolbar监听事件
         */
        table.on('toolbar(currentTableFilter)', function (obj) {
            if (obj.event === 'add') {  // 监听添加操作
                var index = layer.open({
                    title: '添加用户',
                    type: 2,
                    shade: 0.2,
                    maxmin: true,
                    shadeClose: true,
                    area: ['100%', '100%'],
                    content: '/admin/apply/qanswer_add',
                });
                $(window).on("resize", function () {
                    layer.full(index);
                });
            } else if (obj.event === 'delete') {  // 监听删除操作
                var checkStatus = table.checkStatus('currentTableId')
                    , data = checkStatus.data;
                layer.alert(JSON.stringify(data));
            } else if (obj.event === 'LAYTABLE_TIPS') {
                alert('自定义的,不用的话可以将该方法删除')
            }

        });

        //监听表格复选框选择
        table.on('checkbox(currentTableFilter)', function (obj) {
            console.log(obj)
        });

        table.on('tool(currentTableFilter)', function (obj) {
            //获取玩家id code
            var data = obj.data;
            var memberCode = obj.data.code;


            if (obj.event === 'detail') {
                //触发事件  查看内容
                var index = layer.open({
                    title: '玩家详情',
                    type: 2,
                    area: ['95%', '95%'],
                    fixed: false, //不固定
                    shade: 0.5,
                    shadeClose: true,
                    content: '/admin/team/getMember?mark=detail&memberCode=' + memberCode,
                });

            }

        });

    });
    function memberDetail(memberCode){
        //触发事件  查看内容
        var index = layer.open({
            title: '玩家详情',
            type: 2,
            area: ['95%', '95%'],
            fixed: false, //不固定
            shade: 0.5,
            shadeClose: true,
            content: '/admin/team/getMember?memberCode=' + memberCode,
        });
    }
</script>

</body>
</html>